package com.amithkoujalgi.framework.rest.util;
/*
 * package com.razorthink.inblox.api.generic.utils;
 * 
 * import java.util.Properties;
 * 
 * import javax.mail.Message; import javax.mail.MessagingException; import
 * javax.mail.Session; import javax.mail.Transport; import
 * javax.mail.internet.AddressException; import
 * javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage;
 * 
 * import com.razorthink.inblox.module.monitor.rest.pojo.SendErrorMailInput;
 * import com.razorthink.inblox.store.cassandra.pojo.TransactionMessage;
 * 
 * public class MailUtils { private static Properties properties;
 * 
 * private static void setSMTPProperties() { properties =
 * System.getProperties(); properties.put("mail.smtp.port", 587);
 * properties.put("mail.smtp.auth", "true");
 * properties.put("mail.smtp.starttls.enable", "true"); }
 * 
 * private static MimeMessage createMessage(SendErrorMailInput email) throws
 * AddressException, MessagingException { Session mailSession =
 * Session.getDefaultInstance(properties, null); MimeMessage message = new
 * MimeMessage(mailSession); try { if (email.getToAddresses().size() != 0) { for
 * (int i = 0; i < email.getToAddresses().size(); i++) {
 * message.addRecipient(Message.RecipientType.TO, new
 * InternetAddress(email.getToAddresses().get(i) .toString())); System.out
 * .println(email.getToAddresses().get(i).toString()); } } if
 * (email.getCcAddresses().size() != 0) { for (int i = 0; i <
 * email.getCcAddresses().size(); i++) {
 * message.addRecipient(Message.RecipientType.TO, new
 * InternetAddress(email.getCcAddresses().get(i) .toString())); System.out
 * .println(email.getCcAddresses().get(i).toString()); } } if
 * (email.getBccAddresses().size() != 0) { for (int i = 0; i <
 * email.getBccAddresses().size(); i++) {
 * message.addRecipient(Message.RecipientType.TO, new
 * InternetAddress(email.getBccAddresses().get(i) .toString()));
 * System.out.println(email.getBccAddresses().get(i) .toString()); } } if
 * (email.getSubject() != null) { message.setSubject(email.getSubject()); } if
 * (email.getBodyHTML() != null) { message.setContent(email.getBodyHTML(),
 * "text/html");// for a // html // email } if (email.getBodyText() != null)
 * message.setText(email.getBodyText());// for a text email
 * 
 * } catch (Exception e) { e.printStackTrace();
 * //logger.error("Exception while forming the mime mesage "+e.getMessage());
 * throw e; } return message; }
 * 
 * public static TransactionMessage sendMail(SendErrorMailInput mail) throws
 * Exception{ TransactionMessage msg=null; try{ setSMTPProperties(); MimeMessage
 * message=createMessage(mail); Session mailSession =
 * Session.getDefaultInstance(properties, null); String emailHost =
 * "smtp.gmail.com"; String fromUser = mail.getFromAddress();// just the id
 * alone // without @gmail.com String fromUserEmailPassword =
 * mail.getPassword(); Transport transport = mailSession.getTransport("smtp");
 * transport.connect(emailHost, fromUser, fromUserEmailPassword);
 * transport.sendMessage(message, message.getAllRecipients());
 * transport.close(); msg=new TransactionMessage(); msg.setFlag(true);
 * msg.setMessage("Email sent successfully."); } catch(Exception e){ throw e; }
 * return msg; }
 * 
 * }
 */